﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;

namespace Presentation
{
    public partial class NoticiaCadastro : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BntCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                TBNoticia noticia = new TBNoticia();
                noticia.Titulo= txtCadastroTituloNoticia.Text;
                noticia.Corpo = txtCadastroCorpoNoticia.Text;
                noticia.DTFinal = Convert.ToDateTime(txtCadastroDataNoticia.Text);


                using (DBUCNEntities banco = new DBUCNEntities())
                {
                    banco.AddToTBNoticias(noticia);
                    banco.SaveChanges();
                }
                Response.Redirect("NoticiaCadastro.aspx");

            }
            catch (Exception)
            {

                throw;
            } 
        }
    }
}